/**
 * Created by ls-PC on 2016/7/26.
 */

module.exports =function(orm,db) {

    var Evaluation =db.define('evaluation',{
        userto:{type: 'number', rational: false},
        userfrom:{type: 'number', rational: false},
        itemone:{type: 'number', rational: false},
        itemtwo:{type: 'number', rational: false},
        itemthree:{type: 'number', rational: false},
        other:String,
        createdAt : { type: 'date', required: true, time: true }
    },{
        hooks: {
            beforeValidation: function () {
                this.createdAt = new Date();
            }
        },
        methods: {
            serialize: function (){
                return{
                    id:this.id,
                    userto: this.userto,
                    userfrom:this.userfrom,
                    itemone:this.itemone,
                    itemtwo:this.itemtwo,
                    tiemthree:this.itemthree,
                    other:this.other,
                    createdAt : moment(this.createdAt).fromNow()
                }
            }
        }
    })
}
